{notempty name="$cartList"}
{foreach name="cartList" item="v" key="k" }

    <div  class="block" style="margin-top:0px;">
        <div class="item-list">
            <div class="item">
                <div class="inner">
                    <div style="width:60%; float:left; height:98px;">
                        <div class="check-wrapper">
                            <span  class="cart-checkbox {if $v.selected==1}checked {/if}">
                            <input type="checkbox" autocomplete="off" name="cart_select[{$v.id}]" {if $v.selected==1}checked="checked"{/if}  style="display:none;" value="1" onclick="ajax_cart_list();">
                            </span>
                        </div>
                        <div  class="pic">
                            <!--商品图片-->
                            <a href="{:url($v.original_img)}"><img src="{$v.original_img|goods_thum_images2=80,80}"></a>
                        </div>

                        <div class="name">
                            <span>  {$v.goods_name}</span>
                        </div>
                        <div class="attr">
                            <span>{$v.spec_key_name}</span>
                        </div>
                        <div class="num">
                            <div class="xm-input-number">
                                <div class="act_wrap">
                                    <a href="javascript:;" onclick="switch_num(-1,{$v.id},{$v.store_count});" id="jiannum6" class="input-sub active"></a>
                                    <input id="goods_num[{$v.id}]" type="text" onKeyDown='if(event.keyCode == 13) event.returnValue = false' name="goods_num[{$v.id}]"  value="{$v.goods_num}"  class="input-num"  onblur="ajax_cart_list()"/>
                                    <a href="javascript:;" onclick="switch_num(1,{$v.id},{$v.store_count});"  class="input-add active"></a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div style=" position:absolute; right:0px; top:20px; width:100px; height:98px;">
                        <div class="price">
                            <span class="mar_price">￥{$v.market_price}元</span>
                            <br>
                            <span>￥{$v.shop_price}元</span>
                        </div>
                        <div class="delete">
                            <a  onclick="ajax_del_cart({$v.id})">
                                <!--删除按钮-->
                                <div class="icon-shanchu"></div>
                            </a>
                        </div>
                    </div>
                    <div style="height:0px; line-height:0px; clear:both;"></div>
                </div>
                <div class="append"></div>
            </div>
        </div>
    </div>
{/foreach}
{/notempty}
{empty name="$cartList"}
    <div class="screen-wrap fullscreen login">
        <section id="cart-content">
            <div class="qb_tac" style="padding:50px 0">
                <img src="/mobiled/images/flow/empty_cart.png" width="100" height="95">
                <br>购物车还是空的</div>
            <div class="qb_gap" style="width:60%; margin:0 auto;">
                <a href="{:Url('Index/index')}" class="mod_btn btn_strong">马上逛逛</a>
            </div>
        </section>
        <div style="height:72px;"></div>
        <section class="f_mask" style="display: none;"></section>
        <section class="f_block" id="choose" style="height:0px;"></section>
    </div>
{else}
    <div class="bottom-panel">
        <div class="quanxuan">
            <div class="check-wrapper">
                <span class="cart-checkbox" onclick="chkAll_onclick()"></span><span class="cart-checktext">全选</span>
            </div>
        </div>
        <div class="info">
            <span class="hot" id="cart_amount_desc"><em>总计：</em>￥{$total_price.total_fee}元</span>
            <br>
            <span class="hot_text">不含运费</span>
        </div>
        <div class="right">
            <input type="button" href="javascript:void();"  onclick="return selcart_submit();" class="xm-button " value="去结算"></div>
    </div>
{/empty}
<script src="/layer/layer.js"></script>
<script type="text/javascript">
    $(".check-wrapper .cart-checkbox").click(function(){
        if($(this).hasClass('checked')){
            $(this).removeClass('checked');
            $(this).find('input').attr('checked',false);
        }else{
            $(this).addClass('checked');
            $(this).find('input').attr('checked',true);
        }
        ajax_cart_list();
    })

    var is_checked = true;
    $('.inner .cart-checkbox').each(function(){
        if(!$(this).hasClass('checked'))
        {
            is_checked = false;
            return false;
        }
    });
    if(is_checked){
        $('.quanxuan .cart-checkbox').addClass('checked');
    }else
    {
        $('.quanxuan .cart-checkbox').removeClass('checked');
    }

    function chkAll_onclick()
    {
        if($('.quanxuan .cart-checkbox').hasClass('checked')){
            $('.quanxuan .cart-checkbox').removeClass('checked');
            $('.inner .cart-checkbox').removeClass('checked');
            $("input[name^='cart_select']").prop('checked',false);
            is_checked = false;
        }
        else{
            $('.quanxuan .cart-checkbox').addClass('checked');
            $('.inner .cart-checkbox').addClass('checked');
            $("input[name^='cart_select']").prop('checked',true);
            is_checked = true;
        }
        ajax_cart_list();
    }

    // ajax 删除购物车的商品
    function ajax_del_cart(ids)
    {
        $.ajax({
            type : "POST",
            url:"{:url('shopplist')}",
            data:{ids:ids},
            dataType:'json',
            success: function(data){
            }
        });
        ajax_cart_list(); //ajax 请求获取购物车列表

    }


    function selcart_submit()
    {
        var j=0;
        $('input[name^="cart_select"]:checked').each(function(){
            j++;
        });
        if (j>0)
        {
            window.location.href="{:Url('ordercon')}"
        }
        else
        {
            alert('请选择要结算的商品！');
            return false;
        }
    }
</script>
